package com.example.bgxqmanage.mapper;


import com.example.bgxqapi.domain.dao.CommentResponseDao;
import com.example.bgxqapi.domain.dto.ActivityComment;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

/**
 * @author lizijian
 */
@Mapper
public interface CommentDao {

  /**
   * 查找指定id评论
   * @param id
   * @return
   */
  @Results({
      @Result(property = "publisher.username", column = "username"),
      @Result(property = "publisher.id", column = "user_id"),
      @Result(property = "publisher.avatar", column = "avatar")})
  @Select("SELECT *,(SELECT username FROM user WHERE id= user_id) AS username ,(SELECT avatar FROM user WHERE id = user_id) AS avatar FROM activity_comment  WHERE id = #{id}")
  ActivityComment getCommentById(int id);




  @Select("SELECT * FROM comment_response WHERE id = #{id}")
  CommentResponseDao getCommentResponseById(int id);


}
